from datetime import datetime

from fastapi import APIRouter

from app.models import responses
from app.utils import FM

router = APIRouter(
    prefix='/api/v1/index',
    tags=['backend', 'index']
)


@router.get('/trace')
async def trace():
    timestamp = datetime.now().timestamp()
    dt = datetime.utcfromtimestamp(timestamp)
    ymd = int(dt.strftime("%Y%m%d"))
    return responses.SuccessResponse(data={
        'publish': FM.SALT_FACTORS[0],
        'father': FM.SALT_FACTORS[1],
        'mother': FM.SALT_FACTORS[2],
        'trace_id': FM.generate_trace(timestamp),
        'date': ymd
    })
